package com.wchat.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wchat.ChatMsgsVo;
import com.wchat.bean.entity.ChatMsgs;
import com.wchat.bean.entity.FriendMsgs;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author : willian fu
 * @date : 2021/9/1
 */
public interface ChatMsgsMapper extends BaseMapper<ChatMsgs> {

    @Select("SELECT * FROM chat_msgs WHERE ((sender = #{myId} AND target = #{userId}) " +
            "OR (sender = #{userId} AND target = #{myId})) \n" +
            "AND is_send = #{isSend} AND chat_type = #{type} AND recall = 0 ${condition} " +
            "ORDER BY created ASC LIMIT #{size}")
    List<ChatMsgsVo> getHistoryMsg(@Param("myId") Integer myId,
                                   @Param("userId") Integer userId,
                                   @Param("condition") String condition,
                                   @Param("type") String type,
                                   @Param("size") Integer size,
                                   @Param("isSend") Boolean isSend);
}
